Skip to content

fix(@angular/ssr): introduce DI token to signal route discovery process#32491

Merged
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:route-extractor
Mar 3, 2026
Merged

fix(@angular/ssr): introduce DI token to signal route discovery process#32491
alan-agius4 merged 1 commit intoangular:mainfrom
alan-agius4:route-extractor

Conversation

@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Feb 13, 2026

A new DI token, IS_DISCOVERING_ROUTES, is introduced to provide a clear signal for when the application is operating in route discovery mode. This token is provided with the value true within the route extraction providers. Other services and components can inject this token to conditionally alter their behavior, for instance, to disable functionality that is not required or could interfere with the route discovery process.

Closes #32474

@alan-agius4 alan-agius4 requested a review from dgp1130 February 13, 2026 15:25
@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 13, 2026
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/ssr labels Feb 13, 2026
Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

My personal opinion is that we would want to discourage overall use of this token as I think server startup should be generally cheap, hermetic, and stable (in the sense that it does the same thing every time). If you rely on unique runtime dependencies which you don't need for route discovery and are problematic for that use case, I feel like there are potentially better ways to accomplish what most developers need.

That said, reality is always messy and I can see cases where this is useful or Angular is lacking the higher-level APIs which might be a better fit, so no objection from me on landing this.

Copy link
Collaborator

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually one other thought: Can we have a test somewhere that discovering routes sets this token correctly while SSR/CSR does not?

@Platonn
Copy link
Contributor

Platonn commented Feb 19, 2026

Hi Team, since the PR was approved last week, is there a chance we could squeeze it into 21.2.0?

@alan-agius4 alan-agius4 removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Mar 3, 2026
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 3, 2026
A new DI token, `IS_DISCOVERING_ROUTES`, is introduced to provide a clear signal for when the application is operating in route discovery mode.
This token is provided with the value `true` within the route extraction providers. Other services and components can inject this token to conditionally alter their behavior, for instance, to disable functionality that is not required or could interfere with the route discovery process.

Closes angular#32474
@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release and removed target: minor This PR is targeted for the next minor release labels Mar 3, 2026
@alan-agius4 alan-agius4 changed the title feat(@angular/ssr): introduce DI token to signal route discovery process fix(@angular/ssr): introduce DI token to signal route discovery process Mar 3, 2026
@alan-agius4 alan-agius4 merged commit 0f41585 into angular:main Mar 3, 2026
61 of 62 checks passed
@alan-agius4 alan-agius4 deleted the route-extractor branch March 3, 2026 15:20
@alan-agius4
Copy link
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/ssr detected: feature PR contains a feature commit target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow detecting or skipping APP_INITIALIZERs during build-time route-extraction phase, with outputMode: server

4 participants